#ifndef UPDATERDIALOG_H
#define UPDATERDIALOG_H

#include <QtGui>

#include "updatercore.h"

namespace Ui {
    class UpdaterDialog;
}

class UpdaterDialog : public QDialog, protected IUpdaterHandler
{
    Q_OBJECT
public:
    UpdaterDialog(const QString &filename = "",
                  const QString &installResult = "",
                  QWidget *parent = 0);
    ~UpdaterDialog();

    void setInstallResult(const QString &result)
    { myInstallResult = result; }

public slots:
    void start();

//    void setInstallList(const QString &list_name);
//    void install();

    void installFinished();

protected:
    void changeEvent(QEvent *e);
    void closeEvent(QCloseEvent *e);

    virtual void onModuleDownload(const ModuleInfo &mi);
    virtual void onModuleInstall(const ModuleInfo &mi);
    virtual void onFinished();

    int detachAndRun(const QString &local_dir,
                     const QStringList &files,
                     const QString &exe_name,
                     const QStringList &args);

protected slots:
    void on_pbCancel_clicked();

private:
    Ui::UpdaterDialog *ui;

    UpdaterCore *upd;

    QString myInputFilename, myInstallFilename, myInstallResult;
};

#endif // UPDATERDIALOG_H
